import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:myflutterproject/basematerialwidgetsdemo.dart';

class LayoutBuilderDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('LayoutBuilder'),
        centerTitle: true,
      ),
      body:layoutbuilder()
    );
  }

}

class layoutbuilder extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(builder: (context,constraints){
      return Center(
        child: Column(
          children: <Widget>[
            TextWidget('高度自定义，宽度自动沾满全屏'),
            Image.network('https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0/docs/imgs/image-20180829163427556.png',
            fit: BoxFit.fill,width: constraints.maxWidth,height: 200,),
            Text('图片',style: TextStyle(fontSize: 15,color: Colors.black54),)
          ],
        ),
      );
    });
  }
}